home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import com.extensibility.util.Debug;
- import com.extensibility.util.StringUtilities;
- import java.io.EOFException;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Enumeration;
- import java.util.Hashtable;
- import java.util.Stack;
- import java.util.Vector;
-
- public final class DTDParser {
- Stack sectionStack = new Stack();
- Stack readerStack = new Stack();
- ReaderContext readerContext;
- DTDParserFactoryIntf factory;
- char parseChar;
- Hashtable internalGEs = new Hashtable();
- Hashtable externalGEs = new Hashtable();
- boolean sgml;
- boolean signalEOF;
- StringBuffer currentSyntax;
- StringBuffer ignoredText;
- boolean autoInsertPEs;
- boolean autoInsertGEs;
- ReaderContext peStart;
- long totalCharsToParse;
- long charsParsedSoFar;
- boolean inParser;
- URI documentURI;
- private ParserException dummyError;
- boolean extendedModelSytax;
- static final int[] KLEENE_1 = new int[]{1, 1};
- static final int[] KLEENE_PLUS = new int[]{1, Integer.MAX_VALUE};
- static final int[] KLEENE_QUESTION = new int[]{0, 1};
- static final int[] KLEENE_STAR = new int[]{0, Integer.MAX_VALUE};
- private static final int SDATA = 1;
- private static final int CDATA = 2;
- // $FF: renamed from: PI int
- private static final int field_0 = 3;
- private static final int STARTTAG = 4;
- private static final int ENDTAG = 5;
- // $FF: renamed from: MD int
- private static final int field_1 = 6;
- // $FF: renamed from: MS int
- private static final int field_2 = 7;
-
- public static boolean isName(String var0) {
- if (var0 != null && var0.length() != 0) {
- int var1 = 0;
- if (var0.charAt(0) == '%' && var0.length() > 1) {
- ++var1;
- } else if (var0.charAt(0) == '&' && var0.length() > 1) {
- ++var1;
- }
-
- if (!isNameStartChar(var0.charAt(var1))) {
- return false;
- } else {
- for(int var2 = var1 + 1; var2 < var0.length(); ++var2) {
- if (!isNameChar(var0.charAt(var2))) {
- return var0.charAt(var2) == ';' && var2 == var0.length() - 1;
- }
- }
-
- return true;
- }
- } else {
- return false;
- }
- }
-
- public static boolean isNmToken(String var0) {
- if (var0 != null && var0.length() != 0) {
- for(int var1 = 0; var1 < var0.length(); ++var1) {
- if (!isNameChar(var0.charAt(var1)) && (var0.charAt(var1) != '%' || var1 != 0) && (var0.charAt(var1) != '&' || var1 != 0) && (var0.charAt(var1) != ';' || var1 != var0.length() - 1)) {
- return false;
- }
- }
-
- return true;
- } else {
- return false;
- }
- }
-
- public static boolean isNames(String var0) {
- try {
- Vector var1 = DTDUtilities.parseNameList(var0, '\u0000');
-
- for(int var5 = 0; var5 < var1.size(); ++var5) {
- if (!isName((String)var1.elementAt(var5))) {
- boolean var3 = false;
- return var3;
- }
- }
-
- return true;
- } catch (ParserException var4) {
- boolean var2 = false;
- return var2;
- }
- }
-
- public static boolean isNmTokens(String var0) {
- try {
- Vector var1 = DTDUtilities.parseNameList(var0, '\u0000');
-
- for(int var5 = 0; var5 < var1.size(); ++var5) {
- if (!isNmToken((String)var1.elementAt(var5))) {
- boolean var3 = false;
- return var3;
- }
- }
-
- return true;
- } catch (ParserException var4) {
- boolean var2 = false;
- return var2;
- }
- }
-
- public static boolean isNameChar(char var0) {
- return var0 >= 'A' && var0 <= 'Z' || var0 >= 'a' && var0 <= 'z' || var0 >= '0' && var0 <= '9' || var0 == '-' || var0 == '_' || var0 == '.' || var0 == ':' || var0 >= 192 && var0 <= 214 || var0 >= 216 && var0 <= 246 || var0 >= 248 && var0 <= 255 || var0 > 255;
- }
-
- public static boolean isPubId(String var0) {
- for(int var1 = 0; var1 < var0.length(); ++var1) {
- if (!isPubIDChar(var0.charAt(var1))) {
- return false;
- }
- }
-
- return true;
- }
-
- public static boolean isPubIDChar(char var0) {
- return true;
- }
-
- public static boolean isNameStartChar(char var0) {
- return var0 >= 'A' && var0 <= 'Z' || var0 >= 'a' && var0 <= 'z' || var0 == '_' || var0 == ':' || var0 >= 192 && var0 <= 214 || var0 >= 216 && var0 <= 246 || var0 >= 248 && var0 <= 255 || var0 > 255;
- }
-
- public static boolean isOccuranceChar(char var0) {
- return var0 == '?' || var0 == '+' || var0 == '*';
- }
-
- public static boolean isDigitChar(char var0) {
- return var0 >= '0' && var0 <= '9';
- }
-
- public static boolean isWhiteChar(char var0) {
- return var0 == ' ' || var0 == '\t' || var0 == '\r' || var0 == '\n';
- }
-
- public static boolean isConnectorChar(char var0) {
- return var0 == ',' || var0 == '|';
- }
-
- public static boolean isWhiteString(String var0) {
- for(int var1 = 0; var1 < var0.length(); ++var1) {
- if (!isWhiteChar(var0.charAt(var1))) {
- return false;
- }
- }
-
- return true;
- }
-
- public final boolean isSGML() {
- return this.sgml;
- }
-
- public final void setExtendedModelSyntax(boolean var1) {
- this.extendedModelSytax = var1;
- }
-
- public final boolean supportsExtendedModelSyntax() {
- return this.extendedModelSytax;
- }
-
- public void setSGML(boolean var1) {
- this.sgml = var1;
- }
-
- public DTDParser(URI var1, DTDParserFactoryIntf var2, boolean var3) throws IOException {
- this.internalGEs.put("lt", "<");
- this.internalGEs.put("gt", ">");
- this.internalGEs.put("amp", "&");
- this.internalGEs.put("apos", "'");
- this.internalGEs.put("quot", """);
- this.sgml = false;
- this.signalEOF = true;
- this.currentSyntax = new StringBuffer();
- this.autoInsertPEs = true;
- this.autoInsertGEs = false;
- this.peStart = null;
- this.totalCharsToParse = -1L;
- this.charsParsedSoFar = 0L;
- this.inParser = false;
- this.dummyError = new ParserException(0, ' ');
- this.extendedModelSytax = false;
- this.documentURI = var1;
- this.factory = var2;
- this.totalCharsToParse = var1.getLength();
- this.sgml = var3;
- this.readerContext = new ReaderContext(1, var1);
- }
-
- private DTDParser(String var1, DTDParserFactoryIntf var2) {
- this.internalGEs.put("lt", "<");
- this.internalGEs.put("gt", ">");
- this.internalGEs.put("amp", "&");
- this.internalGEs.put("apos", "'");
- this.internalGEs.put("quot", """);
- this.sgml = false;
- this.signalEOF = true;
- this.currentSyntax = new StringBuffer();
- this.autoInsertPEs = true;
- this.autoInsertGEs = false;
- this.peStart = null;
- this.totalCharsToParse = -1L;
- this.charsParsedSoFar = 0L;
- this.inParser = false;
- this.dummyError = new ParserException(0, ' ');
- this.extendedModelSytax = false;
- URI var3 = URI.makeStringURI(var1);
- this.documentURI = var3;
- this.factory = var2;
- this.totalCharsToParse = var3.getLength();
- this.sgml = false;
-
- try {
- this.readerContext = new ReaderContext(1, var3);
- } catch (Exception var5) {
- }
-
- }
-
- public void parse() throws IOException {
- this.inParser = true;
- this.factory.parseBegun(this);
-
- while(true) {
- this.currentSyntax.setLength(0);
-
- label106: {
- try {
- if (this.parseChar != '<') {
- this.autoInsertPEs = false;
- this.skipWhite();
- }
- } catch (ParserException var9) {
- if (var9.getOriginal() != null && !this.isRecoverableException(var9.getOriginal())) {
- if (!(var9.getOriginal() instanceof EOFException)) {
- this.parseError(var9, true);
- this.inParser = false;
- throw (IOException)var9.getOriginal();
- }
- break label106;
- }
-
- this.parseError(var9, true);
- } finally {
- this.autoInsertPEs = true;
- }
-
- try {
- this.parseExtSubsetDecl();
- continue;
- } catch (ParserException var8) {
- this.parseError(var8, true);
- if (this.isRecoverableException(var8.getOriginal())) {
- continue;
- }
-
- if (!(var8.getOriginal() instanceof EOFException)) {
- this.inParser = false;
- this.factory.parseEnded(this);
- throw (IOException)var8.getOriginal();
- }
- }
- }
-
- this.inParser = false;
- this.factory.parseEnded(this);
- return;
- }
- }
-
- private boolean isRecoverableException(Exception var1) {
- if (var1 == null) {
- return true;
- } else if (var1 instanceof FileNotFoundException) {
- return true;
- } else if (var1 instanceof IOException) {
- return false;
- } else {
- Debug.assert(var1);
- return false;
- }
- }
-
- private void parseError(ParserException var1, boolean var2) {
- int var3 = this.currentSyntax.length();
- if (var2) {
- try {
- for(this.autoInsertPEs = false; this.parseChar != -1 && this.parseChar != '>' && this.parseChar != '<'; this.read()) {
- if (this.isSGML() && this.tryRead("--")) {
- this.parseUntil("--");
- }
- }
- } catch (ParserException var9) {
- } finally {
- this.autoInsertPEs = true;
- }
-
- if (this.parseChar == '<') {
- this.currentSyntax.setLength(this.currentSyntax.length() - 1);
- }
- }
-
- this.trimWhite(this.currentSyntax);
- var1.setSource(this.currentSyntax.toString());
- var1.setSourcePos(var3);
- var1.setSourceLinePos(this.readerContext.getLine());
- var1.setContext(this.readerContext, this.readerStack);
- this.factory.createError(var1);
- }
-
- public void parseExtSubsetDecl() throws ParserException {
- this.currentSyntax.setLength(1);
- this.currentSyntax.setCharAt(0, this.parseChar);
- switch (this.parseChar) {
- case '%':
- this.parsePEReference(true);
- break;
- case '<':
- this.parseMarkupDecl();
- break;
- case ']':
- this.read();
- if (this.parseChar != ']') {
- throw new ParserException(63, this.parseChar);
- }
-
- this.read();
- if (this.parseChar != '>') {
- throw new ParserException(63, this.parseChar);
- }
-
- String var1 = this.sectionStack.isEmpty() ? "" : (String)this.sectionStack.pop();
- if (this.isCondition(var1)) {
- this.factory.createConditionalClose(this.readerContext.getURI(), this.getAndResetIgnoredText());
- }
- break;
- default:
- throw new ParserException(31, this.parseChar);
- }
-
- }
-
- private String getAndResetIgnoredText() {
- if (this.sectionStack != null && this.ignoredText != null) {
- for(int var1 = 0; var1 < this.sectionStack.size(); ++var1) {
- String var2 = (String)this.sectionStack.elementAt(var1);
- if (this.isIgnore(var2)) {
- return null;
- }
- }
-
- String var3 = this.ignoredText.toString();
- this.ignoredText = null;
- return var3;
- } else {
- return null;
- }
- }
-
- private boolean isCondition(ReaderContext var1) {
- return this.isCondition(StringUtilities.trimTrailingWhitespace(var1.getValue()));
- }
-
- private boolean isIgnore(String var1) {
- return var1.equals("IGNORE");
- }
-
- private boolean isCondition(String var1) {
- if (this.isSGML()) {
- var1 = var1.toUpperCase();
- }
-
- return var1.equals("IGNORE") || var1.equals("INCLUDE");
- }
-
- void parseMarkupDecl() throws ParserException {
- this.read();
- switch (this.parseChar) {
- case '!':
- this.read();
- switch (this.parseChar) {
- case '-':
- this.read();
- if (this.parseChar != '-') {
- throw new ParserException(16, this.parseChar);
- }
-
- this.parseComment();
- return;
- case '[':
- this.skipWhite();
- Object var1 = null;
- String var2 = null;
- String var4;
- if (this.peStart != null && this.isCondition(this.peStart)) {
- var4 = StringUtilities.trimTrailingWhitespace(this.peStart.getValue());
- var2 = this.peStart.getName();
- this.popReaderContext(this.peStart, true);
- this.peStart = null;
- this.checkWhite();
- } else {
- var4 = StringUtilities.trimTrailingWhitespace(this.parseCaps());
- }
-
- var4 = var4.toUpperCase();
- this.sectionStack.push(var4);
- if (!this.isCondition(var4)) {
- throw new ParserException(61, var4);
- }
-
- this.factory.createConditionalOpen(var4, var2, this.readerContext.getURI());
- this.checkWhite();
- if (this.parseChar != '[') {
- throw new ParserException(62, this.parseChar);
- }
-
- if (this.isIgnore(var4) && this.ignoredText == null) {
- this.ignoredText = new StringBuffer();
- }
-
- return;
- default:
- if (this.peStart != null) {
- }
-
- String var3 = this.parseCaps();
- if (var3.equals("ELEMENT")) {
- this.parseElementDecl();
- } else if (var3.equals("ATTLIST")) {
- this.parseAttListDecl();
- } else if (var3.equals("ENTITY")) {
- this.parseEntityDecl();
- } else {
- if (!var3.equals("NOTATION")) {
- throw new ParserException(30, var3);
- }
-
- this.parseNotationDecl();
- }
-
- if (this.isSGML() && this.parseChar == '-') {
- this.parseInlineComment(false);
- }
-
- if (this.checkWhite() != '>') {
- throw new ParserException(29, this.parseChar);
- }
-
- return;
- }
- case '?':
- this.parsePI();
- }
-
- }
-
- boolean inIgnoreSection() {
- return this.ignoredText != null;
- }
-
- String parseGEReference(boolean var1, boolean var2) throws ParserException {
- this.read();
- if (this.isSGML()) {
- this.checkWhite();
- }
-
- String var3 = this.parseName();
- if (this.inIgnoreSection()) {
- this.ignoredText.append('&');
- this.ignoredText.append(var3);
- this.ignoredText.append(';');
- return var3;
- } else {
- if (this.parseChar != ';') {
- if (!this.isSGML()) {
- throw new ParserException(67, this.parseChar);
- }
-
- this.parseError(new ParserException(110, this.parseChar, 1), false);
- }
-
- String var4;
- if (var3.charAt(0) == '#') {
- if (var3.length() <= 2) {
- throw new ParserException(66, var3);
- }
-
- int var5;
- try {
- if (var3.charAt(1) == 'x') {
- var5 = Integer.parseInt(var3.substring(2, var3.length()), 16);
- } else {
- var5 = Integer.parseInt(var3.substring(1, var3.length()));
- }
- } catch (NumberFormatException var7) {
- throw new ParserException(66, var3);
- }
-
- var4 = (new Character((char)var5)).toString();
- } else if (var1) {
- if (!var2) {
- throw new ParserException(66, var3);
- }
-
- var4 = String.valueOf(String.valueOf("&").concat(String.valueOf(var3))).concat(String.valueOf(this.parseChar));
- } else {
- var4 = (String)this.internalGEs.get(var3);
- }
-
- if (var4 == null) {
- throw new ParserException(68, var3);
- } else {
- this.saveErrorContext();
- this.readerStack.push(this.readerContext);
- this.readerContext = new ReaderContext(var4, 2, var3, var4, this.readerContext.getURI());
- return var3;
- }
- }
- }
-
- private void saveErrorContext() {
- if (this.readerContext.getType() == 1) {
- this.dummyError.setSourceLinePos(this.readerContext.getLine());
- this.dummyError.setContext(this.readerContext, this.readerStack);
- }
-
- }
-
- protected boolean isInReaderStack(URI var1) {
- for(int var2 = 0; var2 < this.readerStack.size(); ++var2) {
- ReaderContext var3 = (ReaderContext)this.readerStack.elementAt(var2);
- if (var3.getURI().equals(var1)) {
- return true;
- }
- }
-
- return false;
- }
-
- String parsePEReference(boolean var1) throws ParserException {
- this.read();
- if (this.isSGML()) {
- this.checkWhite();
- }
-
- String var2 = this.parseName();
- boolean var3 = !var1;
- if (this.inIgnoreSection()) {
- this.ignoredText.append('%');
- this.ignoredText.append(var2);
- this.ignoredText.append(';');
- return var2;
- } else {
- if (this.parseChar != ';') {
- if (!this.isSGML()) {
- throw new ParserException(67, this.parseChar);
- }
-
- this.parseError(new ParserException(110, this.parseChar, 0), false);
-
- try {
- this.parseChar = (char)this.readerContext.unread(this.parseChar);
- } catch (EOFException var10) {
- throw new ParserException(var10, var2);
- }
- }
-
- String var4 = this.factory.getPE(true, var2);
- String var6 = "";
- if (var4 != null) {
- this.saveErrorContext();
- this.readerStack.push(this.readerContext);
- this.readerContext = new ReaderContext(String.valueOf(String.valueOf(" ").concat(String.valueOf(var4))).concat(String.valueOf(" ")), 4, var2, var4, this.readerContext.getURI());
- } else if (var3) {
- this.saveErrorContext();
- this.readerStack.push(this.readerContext);
- this.readerContext = new ReaderContext("", 4, var2, "", this.readerContext.getURI());
- this.parseError(new ParserException(69, var2), false);
- } else {
- var6 = this.factory.getPE(false, var2);
- if (var6 == null) {
- throw new ParserException(69, var2);
- }
-
- if (var6.length() == 0) {
- this.parseError(new ParserException(88, var2), false);
- } else {
- URI var7 = this.readerContext.getURI();
- URI var8 = new URI(var7, var6);
- if (this.isInReaderStack(var8)) {
- throw new ParserException(98, var6);
- }
-
- this.totalCharsToParse += var8.getLength();
-
- try {
- ReaderContext var9 = new ReaderContext(var8, 5, var2, var8);
- this.readerStack.push(this.readerContext);
- this.readerContext = var9;
- this.factory.createExternalSubsetOpen(var2, var8, var7);
- } catch (Exception var11) {
- this.parseError(var11 instanceof ParserException ? (ParserException)var11 : new ParserException(var11, var6), false);
- this.factory.createExternalSubsetOpen(var2, var8, var7);
- this.factory.createExternalSubsetClose();
- }
- }
- }
-
- this.read();
- return var2;
- }
- }
-
- void parsePI() throws ParserException {
- this.skipWhite();
- String var1 = this.parseName();
- String var2 = this.parseUntil(this.isSGML() ? ">" : "?>");
- if (var1.equals("xml")) {
- Object var3 = null;
-
- try {
- var7 = XMLStringUtilities.getNameValuePairs(var2);
- } catch (Exception var6) {
- throw new ParserException(275, var2);
- }
-
- if (var7 != null) {
- if (var7.containsKey("encoding")) {
- String var4 = (String)var7.get("encoding");
- this.factory.setEncoding(var4);
- if (!XMLReader.supportsEncoding(var4)) {
- throw new ParserException(274, var4, 1);
- }
- }
-
- Enumeration var8 = var7.keys();
-
- while(var8.hasMoreElements()) {
- String var5 = (String)var8.nextElement();
- if (!var5.equals("encoding")) {
- this.parseError(new ParserException(999, String.valueOf("All attributes but 'encoding' dropped from 'xml' PI; found: ").concat(String.valueOf(var5))), false);
- }
- }
- }
- } else if (var1.toLowerCase().startsWith("xml")) {
- this.factory.createPI(var1, var2, this.readerContext.getURI());
- this.parseError(new ParserException(273, var1, 1), false);
- } else {
- this.factory.createPI(var1, var2, this.readerContext.getURI());
- }
-
- }
-
- void parseComment() throws ParserException {
- this.autoInsertPEs = false;
-
- try {
- if (this.isSGML()) {
- while(true) {
- String var6 = this.parseUntil("--");
- this.factory.createComment(var6);
- this.skipWhite();
- if (this.parseChar == '>') {
- break;
- }
-
- if (!this.tryRead("--")) {
- throw new ParserException(130, this.parseChar);
- }
- }
- } else {
- String var1 = this.parseUntil("-->");
- this.factory.createComment(var1);
- }
- } finally {
- this.autoInsertPEs = true;
- }
-
- }
-
- void parseElementDecl() throws ParserException {
- Vector var1 = null;
- this.skipWhite();
- String var2;
- if (this.isSGML() && this.parseChar == '(') {
- var1 = this.parseNameList();
- var2 = (String)var1.firstElement();
- } else {
- var2 = this.parseName();
- }
-
- this.checkWhite(true);
- if (this.peStart != null) {
- }
-
- while(this.isSGML() && this.parseChar == '-' && this.tryRead("--")) {
- this.parseInlineCommentInterior(true);
- }
-
- if (this.isSGML() && (this.parseChar == '-' || this.parseChar == 'o' || this.parseChar == 'O')) {
- this.skipWhite();
- if (this.parseChar != '-' && this.parseChar != 'o' && this.parseChar != 'O') {
- throw new ParserException(46, this.parseChar);
- }
-
- this.skipWhite();
- this.parseError(new ParserException(101, "", 0), false);
- }
-
- this.factory.createElementDecl(var2, this.readerContext.getURI());
- this.parseModel(',', true);
- this.checkWhite();
-
- while(this.isSGML() && (this.parseChar == '-' || this.parseChar == '+')) {
- if (this.parseChar == '-' && this.tryRead("--")) {
- this.parseInlineCommentInterior(false);
- } else {
- int var3 = this.currentSyntax.length();
- this.read();
- this.parseParentheses();
- this.parseError(new ParserException(111, this.currentSyntax.toString().substring(var3 - 1, this.currentSyntax.length()), 1), false);
- this.checkWhite();
- }
- }
-
- if (this.isSGML() && var1 != null) {
- for(int var4 = 1; var4 < var1.size(); ++var4) {
- this.factory.cloneElementDecl(var2, (String)var1.elementAt(var4));
- }
-
- this.parseError(new ParserException(103, var1.toString(), 0), false);
- }
-
- }
-
- public static void parseModel(String var0, DTDParserFactoryIntf var1, boolean var2, boolean var3) throws ParserException {
- var0 = var0.trim();
- DTDParser var4 = new DTDParser(var0, var1);
- var4.setExtendedModelSyntax(var2);
- var4.signalEOF = false;
- var4.skipWhite();
- var4.parseModel(',', var3);
- }
-
- Vector parseNameList() throws ParserException {
- Vector var1 = new Vector();
-
- do {
- this.skipWhite();
- String var2 = this.parseName();
- var1.addElement(var2);
- this.checkWhite();
- } while(this.parseChar == '|');
-
- if (this.parseChar != ')') {
- throw new ParserException(104, this.parseChar);
- } else {
- this.read();
- return var1;
- }
- }
-
- private int[] occRangeForKleene(char var1) {
- if (var1 == 0) {
- return KLEENE_1;
- } else if (var1 == '+') {
- return KLEENE_PLUS;
- } else if (var1 == '?') {
- return KLEENE_QUESTION;
- } else if (var1 == '*') {
- return KLEENE_STAR;
- } else {
- throw new IllegalArgumentException((new Character(var1)).toString());
- }
- }
-
- char parseModel(char var1, boolean var2) throws ParserException {
- if (this.peStart != null) {
- char var3 = this.factory.createContentTerms(this.peStart.getName(), var2, this.dummyError);
- if (var3 != 0) {
- this.popReaderContext(this.peStart, true);
- this.peStart = null;
- this.checkWhite();
- return var3;
- }
- } else {
- this.checkWhite(true);
- if (this.peStart != null) {
- char var13 = this.factory.createContentTerms(this.peStart.getName(), var2, this.dummyError);
- if (var13 != 0) {
- this.popReaderContext(this.peStart, true);
- this.peStart = null;
- this.checkWhite();
- return var13;
- }
- }
- }
-
- boolean var14 = this.parseChar == '(';
- if (var2 && !var14) {
- try {
- this.parseModelTermConstant();
- char var15 = 0;
- return var15;
- } catch (ParserException var12) {
- this.parseError(var12, false);
- }
- }
-
- if (var14) {
- this.factory.createCMOpen();
- this.skipWhite(true);
- }
-
- int[] var4 = KLEENE_1;
-
- try {
- char var5 = ',';
-
- while(this.parseChar != ')') {
- if (this.parseChar == '\uffff') {
- char var6 = var1;
- return var6;
- }
-
- if (this.parseChar == '(') {
- var5 = this.parseModel(var5, false);
- } else {
- var5 = this.parseModelTerm(var5);
- }
- }
-
- this.read();
- if (this.supportsExtendedModelSyntax() && this.parseChar == '{') {
- var4 = this.parseOccuranceRange();
- } else if (this.parseChar == '?' || this.parseChar == '*' || this.parseChar == '+') {
- var4 = this.occRangeForKleene(this.parseChar);
- this.skipWhite();
- }
-
- this.checkWhite();
- if (this.isSGML() && this.parseChar == '&') {
- this.parseError(new ParserException(102, '&', 1), false);
- var1 = '|';
- this.skipWhite();
- return var1;
- } else {
- if (this.parseChar == '|' || this.parseChar == ',') {
- var1 = this.parseChar;
- this.skipWhite();
- }
-
- return var1;
- }
- } finally {
- if (var14) {
- this.factory.createCMClose(var4, var1);
- }
-
- }
- }
-
- void parseParentheses() throws ParserException {
- if (this.parseChar != '(') {
- throw new ParserException(47, this.parseChar);
- } else {
- int var1 = 1;
-
- while(var1 > 0) {
- this.read();
- if (this.parseChar == '(') {
- ++var1;
- } else if (this.parseChar == ')') {
- --var1;
- }
- }
-
- this.read();
- }
- }
-
- void parseModelTermConstant() throws ParserException {
- String var1 = this.parseCaps();
- byte var2;
- if (var1.equals("ANY")) {
- var2 = 2;
- } else if (var1.equals("EMPTY")) {
- var2 = 3;
- } else {
- if ((!this.isSGML() || !var1.equals("RCDATA")) && !var1.equals("CDATA")) {
- if (this.isSGML()) {
- throw new ParserException(45, ' ');
- }
-
- throw new ParserException(46, ' ');
- }
-
- var2 = 1;
- this.parseError(new ParserException(112, var1, 1), false);
- }
-
- this.factory.createCMTerm(var2);
- }
-
- int parseDigits() throws ParserException {
- String var1 = this.parseNMToken();
-
- try {
- int var2 = Integer.parseInt(var1);
- return var2;
- } catch (NumberFormatException var3) {
- throw new ParserException(93, var1);
- }
- }
-
- int[] parseOccuranceRange() throws ParserException {
- this.skipWhite();
- int var1 = this.parseDigits();
- this.checkWhite();
- if (this.parseChar != ',') {
- throw new ParserException(93, this.parseChar);
- } else {
- this.skipWhite();
- int var2;
- if (this.parseChar == '*') {
- var2 = Integer.MAX_VALUE;
- this.skipWhite();
- } else {
- var2 = this.parseDigits();
- }
-
- this.skipWhite();
- return new int[]{var1, var2};
- }
- }
-
- char parseModelTerm(char var1) throws ParserException {
- int[] var2 = KLEENE_1;
- if (this.peStart != null) {
- char var3 = this.factory.createContentTerms(this.peStart.getName(), false, this.dummyError);
- if (var3 != 0) {
- this.popReaderContext(this.peStart, true);
- this.peStart = null;
- this.checkWhite();
- if (this.supportsExtendedModelSyntax() && this.parseChar == '{') {
- var2 = this.parseOccuranceRange();
- } else if (this.parseChar == '?' || this.parseChar == '*' || this.parseChar == '+') {
- var2 = this.occRangeForKleene(this.parseChar);
- this.skipWhite();
- }
-
- if (this.parseChar == '|' || this.parseChar == ',') {
- var3 = this.parseChar;
- this.skipWhite(true);
- }
-
- this.factory.changeTerms(var2, var3);
- return var3;
- }
- } else {
- this.checkWhite();
- }
-
- String var4 = this.parseTermName();
- if (this.supportsExtendedModelSyntax() && this.parseChar == '{') {
- var2 = this.parseOccuranceRange();
- } else if (this.parseChar != '?' && this.parseChar != '*' && this.parseChar != '+') {
- this.checkWhite();
- } else {
- var2 = this.occRangeForKleene(this.parseChar);
- this.skipWhite();
- }
-
- while(this.parseChar == '-' && this.tryRead("--")) {
- this.parseInlineCommentInterior(false);
- }
-
- if (this.parseChar != '|' && this.parseChar != ',') {
- if (this.isSGML() && this.parseChar == '&') {
- this.parseError(new ParserException(102, '&', 1), false);
- var1 = '|';
- this.skipWhite();
- } else if (this.parseChar != ')' && this.parseChar != '\uffff') {
- throw new ParserException(48, this.parseChar);
- }
- } else {
- var1 = this.parseChar;
- this.skipWhite();
- }
-
- this.factory.createCMTerm(var4, var2, var1);
- return var1;
- }
-
- void parseAttListDecl() throws ParserException {
- Vector var1 = null;
- this.skipWhite();
- if (this.isSGML() && this.parseChar == '#') {
- this.read();
- String var3 = this.parseName();
- throw new ParserException(118, String.valueOf('#').concat(String.valueOf(var3)), 1);
- } else {
- String var2;
- if (this.isSGML() && this.parseChar == '(') {
- var1 = this.parseNameList();
- var2 = (String)var1.firstElement();
- } else {
- var2 = this.parseName();
- }
-
- this.parseAttList(var2, var1);
- }
- }
-
- void parseInlineComment(boolean var1) throws ParserException {
- this.read();
- if (this.parseChar != '-') {
- throw new ParserException(114, this.parseChar);
- } else {
- this.parseInlineCommentInterior(var1);
- }
- }
-
- private void parseInlineCommentInterior(boolean var1, boolean var2) throws ParserException {
- boolean var3 = this.autoInsertPEs;
- this.autoInsertPEs = false;
-
- try {
- String var4 = this.parseUntil("--");
- this.factory.createComment(var4, var1);
- this.read();
- this.autoInsertPEs = true;
- if (var2) {
- this.checkWhite(true);
- }
- } finally {
- this.autoInsertPEs = var3;
- }
-
- }
-
- private void parseInlineCommentInterior(boolean var1) throws ParserException {
- this.parseInlineCommentInterior(var1, true);
- }
-
- void parseAttList(String var1, Vector var2) throws ParserException {
- boolean var4 = true;
- boolean var5 = false;
- this.checkWhite(true);
-
- while(this.parseChar != '>') {
- if (this.peStart != null) {
- if (this.factory.createAttributeGroup(this.peStart.getName(), var1)) {
- this.popReaderContext(this.peStart, true);
- this.peStart = null;
- this.checkWhite(true);
- continue;
- }
-
- this.checkWhite();
- }
-
- Object var7 = null;
- Vector var8 = null;
- if (this.isSGML() && this.parseChar == '-') {
- if (var4) {
- var5 = true;
- }
-
- this.parseInlineComment(var5);
- this.checkWhite(true);
- } else {
- String var9 = this.parseName();
- this.checkWhite();
-
- for(; this.parseChar == '-' && this.tryRead("--"); this.parseInlineCommentInterior(var5)) {
- if (var4) {
- var5 = true;
- }
- }
-
- if (this.parseChar == '(') {
- byte var6 = 10;
- var7 = new Integer(var6);
- var8 = this.parseEnumeration();
- } else {
- this.checkWhite();
- if (this.peStart != null && DTDUtilities.isValidName(this.peStart.getName())) {
- var7 = new String(this.peStart.getName());
- this.popReaderContext(this.peStart, true);
- this.peStart = null;
- this.checkWhite();
- } else {
- String var10 = this.parseCaps();
- byte var12;
- if (var10.equals("CDATA")) {
- var12 = 1;
- } else if (var10.equals("ID")) {
- var12 = 2;
- } else if (var10.equals("IDREF")) {
- var12 = 3;
- } else if (var10.equals("IDREFS")) {
- var12 = 4;
- } else if (var10.equals("ENTITY")) {
- var12 = 5;
- } else if (var10.equals("ENTITIES")) {
- var12 = 6;
- } else if (var10.equals("NMTOKEN")) {
- var12 = 7;
- } else if (var10.equals("NMTOKENS")) {
- var12 = 8;
- } else if (var10.equals("NOTATION")) {
- this.checkWhite();
- if (this.parseChar != '(') {
- throw new ParserException(58, this.parseChar);
- }
-
- var12 = 9;
- var8 = this.parseNotationType();
- } else {
- if (!this.isSGML()) {
- throw new ParserException(56, var10);
- }
-
- if (var10.equals("NUMBER")) {
- var12 = 1;
- this.parseError(new ParserException(106, var10, 0), false);
- } else if (var10.equals("NUMBERS")) {
- var12 = 1;
- this.parseError(new ParserException(106, var10, 0), false);
- } else if (var10.equals("NUTOKEN")) {
- var12 = 7;
- this.parseError(new ParserException(107, var10, 0), false);
- } else if (var10.equals("NAME")) {
- var12 = 7;
- this.parseError(new ParserException(107, var10, 0), false);
- } else if (var10.equals("NUTOKENS")) {
- var12 = 8;
- this.parseError(new ParserException(108, var10, 0), false);
- } else {
- if (!var10.equals("NAMES")) {
- throw new ParserException(56, var10);
- }
-
- var12 = 8;
- this.parseError(new ParserException(108, var10, 0), false);
- }
- }
-
- if (var7 == null) {
- var7 = new Integer(var12);
- }
- }
- }
-
- this.checkWhite();
-
- for(; this.isSGML() && this.parseChar == '-' && this.tryRead("--"); this.parseInlineCommentInterior(var5)) {
- if (var4) {
- var5 = true;
- }
- }
-
- AttrDefaultInfo var13 = this.parseAttrDefault();
- if (var8 == null) {
- this.factory.createAttrDecl(var1, var9, var7, var13.req, var13.def, this.readerContext.getURI());
- } else {
- this.factory.createAttrDecl(var1, var9, var7, var8, var13.req, var13.def, this.readerContext.getURI());
- }
-
- if (this.isSGML() && var2 != null) {
- for(int var11 = 1; var11 < var2.size(); ++var11) {
- this.factory.cloneAttrDecl(var9, var1, (String)var2.elementAt(var11));
- }
-
- this.parseError(new ParserException(105, var2.toString(), 0), false);
- }
-
- this.checkWhite(true);
- var4 = false;
- }
- }
-
- }
-
- AttrDefaultInfo parseAttrDefault() throws ParserException {
- AttrDefaultInfo var1 = new AttrDefaultInfo((DTDParser)null);
- if (this.parseChar == '#') {
- this.read();
- String var2 = this.parseCaps();
- if (var2.equals("REQUIRED")) {
- var1.req = true;
- } else if (var2.equals("IMPLIED")) {
- var1.req = false;
- } else if (var2.equals("FIXED")) {
- var1.req = true;
- this.skipWhite();
- if (this.parseChar == '>') {
- throw new ParserException(10, this.parseChar);
- }
-
- var1.def = this.parseAttValue();
- if (var1.def.indexOf("#CONTENT") == 0) {
- this.factory.createComment(var1.def, true);
- this.parseError(new ParserException(120, var1.def, 1), false);
- var1.def = null;
- }
- } else {
- if ((!this.isSGML() || !var2.equals("CURRENT")) && !var2.equals("CONREF")) {
- throw new ParserException(60, var2);
- }
-
- var1.req = false;
- this.parseError(new ParserException(116, String.valueOf('#').concat(String.valueOf(var2)), 0), false);
- }
- } else {
- if (this.parseChar == '>') {
- throw new ParserException(10, this.parseChar);
- }
-
- var1.def = this.parseAttValue();
- }
-
- return var1;
- }
-
- Vector parseEnumeration() throws ParserException {
- return this.parseEnumeration(false);
- }
-
- Vector parseEnumeration(boolean var1) throws ParserException {
- Vector var2 = new Vector();
- this.autoInsertPEs = false;
-
- try {
- this.skipWhite();
-
- while(true) {
- String var3;
- if (this.parseChar == '%') {
- this.read();
- String var4 = this.parseName();
- if (this.parseChar == ';') {
- this.read();
- } else {
- this.parseError(new ParserException(110, this.parseChar, 1), false);
- }
-
- var3 = String.valueOf(String.valueOf('%').concat(String.valueOf(var4))).concat(String.valueOf(';'));
- } else {
- var3 = var1 ? this.parseName() : this.parseNMToken();
- }
-
- var2.addElement(var3);
- this.checkWhite();
- if (this.parseChar != '|') {
- if (this.parseChar != ')') {
- throw new ParserException(59, this.parseChar);
- }
-
- this.skipWhite();
- return var2;
- }
-
- this.skipWhite(true);
- }
- } finally {
- this.autoInsertPEs = true;
- }
- }
-
- Vector parseNotationType() throws ParserException {
- return this.parseEnumeration(true);
- }
-
- int parseEntityValuePrefix() throws ParserException {
- byte var1 = 0;
- if (this.parseChar != '"' && this.parseChar != '\'') {
- if (this.tryRead("SDATA")) {
- var1 = 1;
- } else if (this.tryRead("CDATA")) {
- var1 = 2;
- } else if (this.tryRead("PI")) {
- var1 = 3;
- } else if (this.tryRead("STARTTAG")) {
- var1 = 4;
- } else if (this.tryRead("ENDTAG")) {
- var1 = 5;
- } else if (this.tryRead("MD")) {
- var1 = 6;
- } else if (this.tryRead("MS")) {
- var1 = 7;
- }
- }
-
- if (var1 != 0) {
- this.skipWhite();
- }
-
- return var1;
- }
-
- void parseEntityDecl() throws ParserException {
- this.autoInsertPEs = false;
- this.skipWhite();
- this.autoInsertPEs = true;
- boolean var1 = this.parseChar == '%';
- if (var1) {
- this.skipWhite();
- }
-
- if (this.isSGML() && this.parseChar == '#') {
- if (this.tryRead("#DEFAULT")) {
- throw new ParserException(127, "#DEFAULT");
- } else if (this.tryRead("#default")) {
- throw new ParserException(127, "#DEFAULT");
- } else {
- this.read();
- throw new ParserException(129, this.parseName());
- }
- } else {
- String var2 = this.parseName();
- this.skipWhite();
-
- while(this.isSGML() && this.parseChar == '-' && this.tryRead("--")) {
- this.parseInlineCommentInterior(true);
- }
-
- int var3 = 0;
- if (this.isSGML()) {
- var3 = this.parseEntityValuePrefix();
- }
-
- while(this.parseChar == '-' && this.tryRead("--")) {
- this.parseInlineCommentInterior(true);
- }
-
- if (this.parseChar != '"' && this.parseChar != '\'') {
- LocRefInfo var5 = this.parseLocRefInfo(var1, false);
- if (var1) {
- this.factory.createParamEntityDecl(var2, var5.pubName, new URI(this.documentURI, var5.sysName), this.readerContext.getURI());
- } else if (var5.notation != null) {
- this.factory.createUnparsedEntityDecl(var2, var5.pubName, new URI(this.documentURI, var5.sysName), var5.notation, this.readerContext.getURI());
- } else {
- this.externalGEs.put(var2, var5.sysName);
- this.factory.createGeneralEntityDecl(var2, var5.pubName, new URI(this.documentURI, var5.sysName), this.readerContext.getURI());
- }
- } else {
- String var4 = this.parseEntityValue();
- if (this.isSGML() && var3 != 0) {
- switch (var3) {
- case 1:
- this.parseError(new ParserException(117, var4, 1), false);
- break;
- case 2:
- this.parseError(new ParserException(121, var4, 1), false);
- break;
- case 3:
- this.parseError(new ParserException(122, var4, 1), false);
- break;
- case 4:
- this.parseError(new ParserException(123, var4, 1), false);
- var4 = String.valueOf(String.valueOf('<').concat(String.valueOf(var4))).concat(String.valueOf('>'));
- break;
- case 5:
- this.parseError(new ParserException(124, var4, 1), false);
- var4 = String.valueOf(String.valueOf("</").concat(String.valueOf(var4))).concat(String.valueOf('>'));
- break;
- case 6:
- this.parseError(new ParserException(125, var4, 1), false);
- var4 = String.valueOf(String.valueOf("<![").concat(String.valueOf(var4))).concat(String.valueOf("]]>"));
- break;
- case 7:
- this.parseError(new ParserException(126, var4, 1), false);
- var4 = String.valueOf(String.valueOf("<!").concat(String.valueOf(var4))).concat(String.valueOf('>'));
- }
- }
-
- if (var1) {
- this.factory.createParamEntityDecl(var2, var4, this.readerContext.getURI());
- } else {
- this.internalGEs.put(var2, var4);
- this.factory.createGeneralEntityDecl(var2, var4, this.readerContext.getURI());
- }
- }
-
- }
- }
-
- LocRefInfo parseLocRefInfo(boolean var1, boolean var2) throws ParserException {
- LocRefInfo var3 = new LocRefInfo((DTDParser)null);
- String var4 = this.parseCaps();
- if (var4.equals("PUBLIC")) {
- this.checkWhite();
- var3.pubName = this.parsePubIdLiteral();
- if (this.isSGML() && this.parseChar == '-') {
- this.parseInlineComment(true);
- }
-
- if (this.parseChar != '>') {
- var3.sysName = this.parseSystemLiteral();
- } else if (var2) {
- var3.sysName = "";
- } else if (var1) {
- var3.sysName = "";
- if (!this.isSGML()) {
- throw new ParserException(76, this.parseChar);
- }
-
- this.parseError(new ParserException(109, this.parseChar, 1), false);
- }
- } else {
- if (!var4.equals("SYSTEM")) {
- throw new ParserException(76, var4);
- }
-
- this.checkWhite();
- var3.sysName = this.parseSystemLiteral();
- }
-
- this.checkWhite();
- if (!var1 && !var2) {
- if (this.tryRead("NDATA")) {
- this.skipWhite();
- var3.notation = this.parseName();
- } else if (this.tryRead("SUBDOC")) {
- this.parseError(new ParserException(128, "SUBDOC", 0), false);
- this.skipWhite();
- } else if (this.tryRead("CDATA")) {
- this.parseError(new ParserException(128, "CDATA", 0), false);
- this.skipWhite();
- this.parseName();
- } else if (this.tryRead("SDATA")) {
- this.parseError(new ParserException(128, "SDATA", 0), false);
- this.skipWhite();
- this.parseName();
- }
- }
-
- return var3;
- }
-
- void parseNotationDecl() throws ParserException {
- this.skipWhite();
- String var1 = this.parseName();
- this.skipWhite();
- if (this.peStart != null) {
- }
-
- LocRefInfo var2 = this.parseLocRefInfo(false, true);
- this.factory.createNotationDecl(var1, var2.pubName, var2.sysName.length() == 0 ? null : new URI(this.documentURI, var2.sysName), this.readerContext.getURI());
- }
-
- char checkWhite(boolean var1) throws ParserException {
- return this.parseChar != ' ' && this.parseChar != '\t' && this.parseChar != '\n' && this.parseChar != '\r' ? this.parseChar : this.skipWhite(var1);
- }
-
- char skipWhite(boolean var1) throws ParserException {
- this.read();
-
- while((this.parseChar == ' ' || this.parseChar == '\t' || this.parseChar == '\n' || this.parseChar == '\r') && (this.peStart == null || !var1)) {
- this.read();
- }
-
- return this.parseChar;
- }
-
- char checkWhite() throws ParserException {
- return this.parseChar != ' ' && this.parseChar != '\t' && this.parseChar != '\n' && this.parseChar != '\r' ? this.parseChar : this.skipWhite();
- }
-
- char skipWhite() throws ParserException {
- this.read();
-
- while(this.parseChar == ' ' || this.parseChar == '\t' || this.parseChar == '\n' || this.parseChar == '\r') {
- this.read();
- }
-
- return this.parseChar;
- }
-
- void trimWhite(StringBuffer var1) {
- int var2 = var1.length();
- if (var2 > 0) {
- switch (var1.charAt(var2 - 1)) {
- case '\t':
- case '\n':
- case '\r':
- case ' ':
- var1.setLength(var2--);
- default:
- }
- }
- }
-
- String parseTermName() throws ParserException {
- StringBuffer var1 = new StringBuffer();
- if (this.peStart != null) {
- }
-
- if (isNameStartChar(this.parseChar) || this.parseChar == '#' || this.supportsExtendedModelSyntax() && this.parseChar == ContentModelTerm.TAG_TYPE_SEPARATOR) {
- var1.append(this.parseChar);
- this.read();
-
- while(this.parseChar != '\uffff' && (isNameChar(this.parseChar) || this.supportsExtendedModelSyntax() && this.parseChar == ContentModelTerm.TAG_TYPE_SEPARATOR)) {
- var1.append(this.parseChar);
- this.read();
- }
- }
-
- return var1.toString();
- }
-
- String parseName() throws ParserException {
- StringBuffer var1 = new StringBuffer();
- if (this.peStart != null) {
- }
-
- if (isNameStartChar(this.parseChar)) {
- var1.append(this.parseChar);
- this.read();
-
- while(isNameChar(this.parseChar)) {
- var1.append(this.parseChar);
- this.read();
- }
- }
-
- return var1.toString();
- }
-
- String parseNMToken() throws ParserException {
- StringBuffer var1 = new StringBuffer();
- if (this.peStart != null) {
- }
-
- while(isNameChar(this.parseChar)) {
- var1.append(this.parseChar);
- this.read();
- }
-
- return var1.toString();
- }
-
- String parseAttValue() throws ParserException {
- StringBuffer var1 = new StringBuffer();
-
- String var4;
- try {
- this.autoInsertPEs = false;
- int var2 = this.readerStack.size();
- if (this.peStart != null) {
- }
-
- if (this.parseChar == '"' || this.parseChar == '\'') {
- char var9 = this.parseChar;
- this.read();
-
- while(this.parseChar != var9 || this.readerStack.size() != var2) {
- if (this.parseChar == '&') {
- this.read();
- var4 = this.parseName();
- if (this.parseChar == ';') {
- this.read();
- } else {
- if (!this.isSGML()) {
- throw new ParserException(90, this.parseChar);
- }
-
- this.parseError(new ParserException(110, this.parseChar, 1), false);
- }
-
- var1.append(String.valueOf(String.valueOf('&').concat(String.valueOf(var4))).concat(String.valueOf(';')));
- } else {
- var1.append(this.parseChar);
- this.read();
- }
- }
-
- this.read();
- var4 = var1.toString();
- return var4;
- }
-
- if (!this.isSGML()) {
- throw new ParserException(10, this.parseChar);
- }
-
- String var3 = this.parseNMToken();
- this.parseError(new ParserException(113, var3, 0), false);
- var4 = var3;
- } finally {
- this.autoInsertPEs = true;
- }
-
- return var4;
- }
-
- String parseCaps() throws ParserException {
- StringBuffer var1 = new StringBuffer();
- if (this.isSGML()) {
- while(this.parseChar >= 'A' && this.parseChar <= 'Z' || this.parseChar >= 'a' && this.parseChar <= 'z') {
- var1.append(this.parseChar);
- this.read();
- }
-
- String var2 = var1.toString();
- return var2.toUpperCase();
- } else {
- while(this.parseChar >= 'A' && this.parseChar <= 'Z') {
- var1.append(this.parseChar);
- this.read();
- }
-
- return var1.toString();
- }
- }
-
- String parseQuote(char var1) throws ParserException {
- int var2 = this.readerStack.size();
- StringBuffer var3 = new StringBuffer();
- this.read();
-
- while(this.parseChar != var1 || this.readerStack.size() != var2) {
- var3.append(this.parseChar);
- this.read();
- }
-
- this.skipWhite();
- return var3.toString();
- }
-
- String parseUntil(String var1) throws ParserException {
- boolean var2 = var1.equals("-->");
- int var3 = this.readerStack.size();
- int var4 = 0;
- StringBuffer var5 = new StringBuffer();
-
- while(var4 < var1.length()) {
- this.read();
- if (this.parseChar == var1.charAt(var4) && this.readerStack.size() == var3) {
- ++var4;
- } else {
- if (var4 > 0) {
- var5.append(var1.substring(0, var4));
- var4 = 0;
- }
-
- var5.append(this.parseChar);
- }
- }
-
- return var5.toString();
- }
-
- String parsePubIdLiteral() throws ParserException {
- if (this.peStart != null) {
- }
-
- if (this.parseChar != '"' && this.parseChar != '\'') {
- throw new ParserException(12, this.parseChar);
- } else {
- return this.parseQuote(this.parseChar);
- }
- }
-
- String parseSystemLiteral() throws ParserException {
- if (this.peStart != null) {
- }
-
- if (this.parseChar != '"' && this.parseChar != '\'') {
- throw new ParserException(11, this.parseChar);
- } else {
- return this.parseQuote(this.parseChar);
- }
- }
-
- String parseEntityValue() throws ParserException {
- int var1 = this.readerStack.size();
- if (this.parseChar != '"' && this.parseChar != '\'') {
- throw new ParserException(8, this.parseChar);
- } else {
- char var2 = this.parseChar;
- StringBuffer var3 = new StringBuffer();
- this.autoInsertPEs = false;
-
- String var4;
- try {
- this.read();
-
- while(this.parseChar != var2) {
- while(this.isSGML() && this.parseChar == '-' && this.tryRead("--")) {
- this.parseInlineCommentInterior(true, false);
- }
-
- var3.append(this.parseChar);
- this.read();
- }
-
- this.autoInsertPEs = true;
- this.skipWhite();
- var4 = var3.toString();
- } finally {
- this.autoInsertPEs = true;
- }
-
- return var4;
- }
- }
-
- boolean tryRead(String var1) throws ParserException {
- try {
- if (this.parseChar != var1.charAt(0)) {
- boolean var6 = false;
- return var6;
- } else {
- this.readerContext.mark(var1.length());
- int var2 = 1;
- if (this.isSGML()) {
- while(var2 < var1.length()) {
- if (Character.toUpperCase((char)this.readerContext.read()) != Character.toUpperCase(var1.charAt(var2++))) {
- this.readerContext.reset();
- boolean var8 = false;
- return var8;
- }
- }
- } else {
- while(var2 < var1.length()) {
- if (this.readerContext.read() != var1.charAt(var2++)) {
- this.readerContext.reset();
- boolean var7 = false;
- return var7;
- }
- }
- }
-
- this.readerContext.reset();
-
- for(int var9 = 1; var9 < var1.length(); ++var9) {
- this.read();
- }
-
- boolean var4 = true;
- return var4;
- }
- } catch (IOException var5) {
- boolean var3 = false;
- return var3;
- }
- }
-
- void read() throws ParserException {
- try {
- Debug.assert(this.parseChar != -1, "Passed eof");
- if (this.peStart != null && !isWhiteChar(this.parseChar)) {
- StringBuffer var1 = new StringBuffer(this.currentSyntax.toString());
- this.currentSyntax.setLength(this.currentSyntax.length() - 1);
- this.currentSyntax.append(String.valueOf(String.valueOf("%").concat(String.valueOf(this.peStart.getName()))).concat(String.valueOf(";")));
- if (this.inIgnoreSection()) {
- this.ignoredText.setLength(this.ignoredText.length() - 1);
- this.ignoredText.append(String.valueOf(String.valueOf("%").concat(String.valueOf(this.peStart.getName()))).concat(String.valueOf(";")));
- }
-
- this.parseError(new ParserException(99, this.peStart.getName(), 1), false);
- this.currentSyntax = var1;
- this.peStart = null;
- }
-
- this.parseChar = (char)this.readerContext.read();
- if (this.parseChar == '\uffff') {
- this.popReaderContext((ReaderContext)null, false);
- } else {
- ++this.charsParsedSoFar;
- this.currentSyntax.append(this.parseChar);
- if (this.inIgnoreSection()) {
- this.ignoredText.append(this.parseChar);
- }
-
- if (this.autoInsertGEs && this.parseChar == '&') {
- int var5 = this.currentSyntax.length() - 1;
- this.parseGEReference(true, false);
- if (this.parseChar == ';') {
- this.read();
- }
-
- this.currentSyntax.setLength(var5);
- } else if (this.autoInsertPEs && this.parseChar == '%') {
- int var4 = this.currentSyntax.length() - 1;
- String var2 = this.parsePEReference(false);
- this.currentSyntax.setLength(var4);
- this.currentSyntax.append(this.parseChar);
- if (this.readerContext.getType() == 4) {
- this.peStart = this.readerContext;
- }
- }
- }
-
- } catch (IOException var3) {
- throw new ParserException(var3, this.readerContext.getURI().getShortName());
- }
- }
-
- boolean isURI(String var1) {
- try {
- new URL(var1);
- boolean var2 = true;
- return var2;
- } catch (MalformedURLException var4) {
- boolean var3 = false;
- return var3;
- }
- }
-
- private void popReaderContext(ReaderContext var1, boolean var2) throws ParserException {
- this.peStart = null;
- if (var2) {
- this.currentSyntax.setLength(this.currentSyntax.length() - 1);
- if (this.inIgnoreSection()) {
- this.ignoredText.setLength(this.ignoredText.length() - 1);
- }
- }
-
- ReaderContext var3 = this.readerContext;
- this.readerContext.close();
- if (!this.readerStack.empty()) {
- if (this.readerContext.getType() == 5) {
- this.factory.createExternalSubsetClose();
- }
-
- this.readerContext = (ReaderContext)this.readerStack.pop();
- this.parseChar = 0;
- if (var1 != null && var3 != var1) {
- this.popReaderContext(var1, false);
- } else {
- this.read();
- }
-
- } else if (this.signalEOF) {
- throw new ParserException(new EOFException(), this.readerContext.getURI().toSource());
- }
- }
-
- public boolean statusIsDone() {
- return !this.inParser;
- }
-
- public long statusTotalCharsToParse() {
- return this.totalCharsToParse;
- }
-
- public long statusCharsParsedSoFar() {
- return this.charsParsedSoFar;
- }
-
- public String statusCurrentURI() {
- return this.readerContext == null ? "" : this.readerContext.getURI().getShortName();
- }
- }
-